package com.lz.autotest.project.testmanage.autoTest.service;

import com.lz.autotest.common.utils.GlobalMap;
import com.lz.autotest.project.testmanage.autoTest.entity.InfResultVo;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author: X
 * @date: Created in 2023/9/25 15:20
 * @Description: 定时执行
 */
@Service
public class TaskService {

    /**
     * @Description: 清除已完成的测试过程
     * @author: X
     * @DateTime: 2023/9/25 15:24
     * @param
     * @return
    **/
    @Scheduled(cron = "0 0 01 ? * *")
    public void ClearInfResult() {
        Set<String> set = GlobalMap.keySetInfResult();
        for (String key : set) {
            InfResultVo result = GlobalMap.getInfResult(key);
            if (result.getIsDone() == 1) {
                GlobalMap.removeInfResult(key);
            }
        }
    }
}
